#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
   @Author: 叶建伟
   @Email: yejw46507@hundsun.com
   @Time: 2023/5/12 16:28
   @File: dataTest.py
"""
from faker import Faker

from random import choice

from DataTest.tabledata.commonData import randomInfo
from DataTest.tabledata.commonData.SQLMontage import read_file, get_sql_key, montage_sql_value
from DataTest.tabledata.commonData.clientInfo import client_info

fake = Faker(locale='zh_CN')


def montage_sql(**kwargs):
    table = kwargs.get('table')
    sql_list = kwargs.get('sql_list')
    sql = read_file(table)
    for key, value in sql.items():
        table_value = {}
        for key_1, value_1 in value[0].items():
            keyLower = key_1.lower()
            table_value.update({keyLower: value_1})
        table_key = get_sql_key(table=table)
        values = montage_sql_value(table=table_value, sql_list=sql_list)
        print(table_key.lower()+values+';')



if __name__ == "__main__":

        client_id = '0002497700008'
        # inner_client_id = client_id
        client_type = '0'
        sql_list = client_info()
        # client_type = choice(['1','2'])
        # sql_list = client_info()
        # client_name = fake.company() #名称
        # occupation_code = '1'



       # contact_address = '广东省韶关市酒厂街11号'
       #  id_type = '01'
        ta_no = '63'
        apply_date = 20240621
        confirm_date = 20240621
        id_no = ' '
        # nationality_code = 'CAF'
        business_flag = '81'
        id_type = ' '
        client_name = 'Abou Bakr Al Djazairi'
        # occupation_code = choice(['37','34','36','15','2','1','14','16','17'])
        # sql_list.update({'client_name':client_name,'client_full_name':client_name})
        sql_list.update({'client_id': client_id,'inner_client_id': client_id,'client_type': client_type,
                         'ta_no':ta_no,'id_type':id_type,'client_name':client_name,'id_no':id_no})
        sql_list.update({'business_flag': business_flag,'apply_date':apply_date,'confirm_date':confirm_date})
        montage_sql(table='fnd_client', sql_list=sql_list)
        montage_sql(table='fnd_fund_account', sql_list=sql_list)
        montage_sql(table='fnd_account_request', sql_list=sql_list)
        # montage_sql(table='fnd_request', sql_list=sql_list)
        # montage_sql(table='amlrc_risklevel', sql_list=sql_list)


